package com.slofzx.nuoda.evaluation.version.controller;

import com.slofzx.nuoda.common.controller.BaseController;
import com.slofzx.nuoda.common.enums.ServiceResult;
import com.slofzx.nuoda.common.vo.AjaxResultVO;
import com.slofzx.nuoda.common.vo.PageResultVO;
import com.slofzx.nuoda.evaluation.version.dto.ProjectReportVersionDTO;
import com.slofzx.nuoda.evaluation.version.dto.ProjectReportVersionQueryDTO;
import com.slofzx.nuoda.evaluation.version.vo.ProjectReportVersionVO;
import com.slofzx.nuoda.evaluation.version.service.ProjectReportVersionService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 评价信息控制层
 *
 * @author nuoda
 * @menu 评价信息
 * @since 2022-08-11 08:55:59
 */
@RestController
@RequestMapping("/project/report_version")
public class ProjectReportVersionController extends BaseController {
    /**
     * 服务对象
     */
    @Autowired
    private ProjectReportVersionService projectReportVersionService;

    /**
     * 通过查询条件查询列表数据
     *
     * @param dto 查询参数
     * @return 列表数据
     */
//    @RequiresPermissions("evaluation:audit")
    @GetMapping("/data")
    public AjaxResultVO<List<ProjectReportVersionVO>> queryList(ProjectReportVersionQueryDTO dto) {
        List<ProjectReportVersionVO> dataList = projectReportVersionService.queryList(dto);
        return PageResultVO.newSuccessResult(dataList, dto.getCount());
    }

    /**
     * 通过查询条件查询列表数据
     *
     * @param dto 查询参数
     * @return 列表数据
     */
//    @RequiresPermissions("evaluation:audit")
    @PostMapping("/query")
    public AjaxResultVO<List<ProjectReportVersionVO>> queryList2(@RequestBody ProjectReportVersionQueryDTO dto) {
        List<ProjectReportVersionVO> dataList = projectReportVersionService.queryList(dto);
        return PageResultVO.newSuccessResult(dataList, dto.getCount());
    }

    /**
     * 创建数据
     *
     * @param dto 参数数据
     * @return 操作结果
     */
    @ResponseBody
    @PostMapping(value = "/create")
    public AjaxResultVO create(@RequestBody ProjectReportVersionDTO dto) {
        ServiceResult resultEnum = projectReportVersionService.create(dto);
        return AjaxResultVO.getInstance(resultEnum);
    }

//    /**
//     * 数据更新
//     *
//     * @param dto
//     * @return 操作结果
//     */
//    @ResponseBody
//    @PostMapping(value = "/update")
//    public AjaxResultVO update(@RequestBody ProjectReportVersionDTO dto) {
//        ServiceResult resultEnum = projectReportVersionService.update(dto);
//        return AjaxResultVO.getInstance(resultEnum);
//    }
//
//    /**
//     * 删除数据
//     *
//     * @param id
//     * @return 操作结果
//     */
//    @ResponseBody
//    @PostMapping(value = "/delete")
//    public AjaxResultVO delete(@RequestParam String id) {
//        ServiceResult resultEnum = projectReportVersionService.deleteById(id);
//        return AjaxResultVO.getInstance(resultEnum);
//    }

    /**
     * 查询单个数据
     *
     * @return id对应数据
     */
    @ResponseBody
    @GetMapping(value = "/info/{id}")
    public AjaxResultVO<ProjectReportVersionVO> queryById(@PathVariable String id) {
        ProjectReportVersionVO vo = projectReportVersionService.queryById(id);
        return AjaxResultVO.newSuccessResult(vo);
    }

    /**
     * 审核版本
     *
     * @param dto 查询参数
     * @return 列表数据
     */
    @RequiresPermissions("evaluation:audit")
    @PostMapping("/audit")
    public AjaxResultVO<ServiceResult> audit(@RequestBody ProjectReportVersionDTO dto) {
        ServiceResult result = projectReportVersionService.audit(dto);
        return AjaxResultVO.getInstance(result);
    }

}
